<template>
  <div>
    <el-table
        :data="tableData"
        style="width: 100%">
      <el-table-column
          label="日期"
          width="180">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.date }}</span>
        </template>
      </el-table-column>
      <el-table-column
          label="厂名"
          width="180">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <p>厂名: {{ scope.row.name }}</p>
            <p>地址: {{ scope.row.address }}</p>
            <div slot="reference" class="name-wrapper">
              <el-tag size="medium">{{ scope.row.name }}</el-tag>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="地址">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.address }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
              size="mini"
              @click="handleImg(scope.$index, scope.row)">图片</el-button>
          <el-button
              size="mini"
              type="danger"
              @click="handleVideo(scope.$index, scope.row)">视频</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog title="图片" :visible.sync="imgDialogVisible"
               width="50%"
               center>
      <el-image :src="imgSrc"></el-image>
    </el-dialog>
    <el-dialog title="图片" :visible.sync="videoDialogVisible"
               width="30%"
               center>
      <dplayer ref="dplayer" :dplayer-data="dplayerData"></dplayer>
    </el-dialog>
  </div>
</template>

<script>
import dplayer from '@/components/DPlayer.vue'
export default {
  components: {
    dplayer
  },
  data() {
    return {
      tableData: [{
        date: '2016-05-02',
        name: '鄂尔多斯XX电厂1',
        address: '鄂尔多斯市xx区xxxx路 1518 号',
        imgSrc: 'https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg'
      }, {
        date: '2016-05-04',
        name: '鄂尔多斯XX厂2',
        address: '鄂尔多斯市xx区xxxx路 1517 弄'
      }, {
        date: '2016-05-01',
        name: '鄂尔多斯XX厂3',
        address: '鄂尔多斯市xx区xxxx路 1519 弄'
      }, {
        date: '2016-05-03',
        name: '鄂尔多斯XX电厂555',
        address: '鄂尔多斯市xx区xxxx路 1516 弄'
      }],
      imgDialogVisible: false,
      videoDialogVisible: false,
      imgSrc: require('../../assets/images/eeds/img_eeds_1.jpeg'),
      dplayerData: {
        style: 'width:100%;height:330px;'
      },
      info: {
        video: require('../../assets/videos/eeds/video_eeds_1.mp4'),
        pic: ''
      }
    }
  },
  created() {
    setTimeout(()=>{
      this.switchVideo()
    },2000)
  },
  methods: {
    handleImg(index, row) {
      this.imgDialogVisible = true;
    },
    handleVideo(index, row) {
      this.videoDialogVisible = true;
    },
    switchVideo() {
      this.$refs.dplayer.switchVideo(this.info)
    }
  }
}
</script>
